package com.hellobike.haxing.modules.order.job;

import com.hellobike.haxing.common.constant.CacheConstant;
import com.hellobike.haxing.common.util.RedisUtil;
import com.hellobike.haxing.modules.order.service.IOrderService;
import com.hellobike.haxing.modules.order.service.IOrderTimeConfigService;
import com.hellobike.haxing.modules.wms.facade.WmsSyncFacade;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 订单定时超时关闭
 */
@Slf4j
@Component
public class OrderPayTimeOutCloseJob {
    @Autowired
    private IOrderService orderService;
    @Autowired
    private RedisUtil redisUtil;

    @Scheduled(fixedDelay = 15 * 1000)
    public void execute() {
        try {
            Object result = redisUtil.get(CacheConstant.ORADER_TIMEOUT_PAY_CLOSE_JOB);
            if (result != null) {
                return;
            }
            redisUtil.set(CacheConstant.ORADER_TIMEOUT_PAY_CLOSE_JOB, 1, 5);
            log.info("==订单超时支付定时任务开始执行==");
            orderService.updatePayTimeOutCloseOrder();
        } catch (Exception e) {
            log.error("订单定时超时关闭定时任务异常", e);
        }

    }
}
